﻿//#define _CRT_SECURE_NO_WARNINGS
////#include<stdio.h>
////#include<ctype.h>
////#include<string.h>
////void Upper(char* c)
////{
////	(*c) -= 32;
////}
////
////int main()
////{
////	char str[] = "Hello World";
////	for (int i = 0; i < strlen(str); i++)
////	{
////		if (islower(str[i]))
////			str[i] = toupper(str[i]);
////			//Upper(&str[i]);
////	}
////	printf("%s", str);
////}
//
////#include<stdio.h>
////#include<string.h>
////int main()
////{
////	char* a = "bbb";
////	char b[] = "abcd";
////	printf("%zd %zd", strlen(a), strlen(b));
////	return 0;
////}
//
//
////#include<stdio.h>
////#include<string.h>
////
////size_t my_strlen(char* str)
////{
////	//计数器
////	size_t count = 0;
////	char* cur = str;
////	while (*cur != '\0')//这里也可以直接写成 while(*cur)，因为'\0'的码值为 0
////		cur++,count++;
////	return count;
////}
////
////int main()
////{
////	char* a = "abcdefg";
////	printf("%zd\n", strlen(a));//对照
////	printf("%zd\n", my_strlen(a));
////	return 0;
////}
//
////#include<stdio.h>
////#include<string.h>
////
////size_t my_strlen(char* str)
////{
////	//指针-指针
////	char* cur = str;
////	while (*cur)
////		cur++;
////	return cur - str;//指针-指针得到的是指针之间的元素个数
////}
////
////int main()
////{
////	char* a = "abcdefg";
////	printf("%zd\n", strlen(a));
////	printf("%zd\n", my_strlen(a));
////	return 0;
////}
//
////#include<stdio.h>
////#include<string.h>
////
////size_t my_strlen(char* str)
////{
////	//不创建临时变量
////	if (!*str)//递归的终止条件
////		return 0;
////	else
////		return 1 + my_strlen(str + 1);
////}
////
////int main()
////{
////	char* a = "abcdefg";
////	printf("%zd\n", strlen(a));
////	printf("%zd\n", my_strlen(a));
////	return 0;
////}
//
////#include<stdio.h>
////#include<string.h>
////
////char* my_strcpy(char* destination, const char* source)
////{
////	//注意返回值，返回的是复制结束后 destination 的首元素地址
////	char* ret = destination;
////	while (*destination++ = *source++);
////	*destination = '\0';//可不要忘了'\0'!
////	return ret;
////}
////
////int main()
////{
////	char str1[] = "abcd";
////	char str2[] = "efghxxxxx";
////	printf("str1 = %s\nstr2 = %s\n\n", str1, str2);
////	//strcpy(str2, str1);
////	my_strcpy(str2, str1);
////	printf("str1 = %s\nstr2 = %s\n\n", str1, str2);
////	return 0;
////}
//
////#include<stdio.h>
////#include<string.h>
////#include<assert.h>
////
////char* my_strcat(char* dest, const char* src)
////{
////	assert(dest && src);//断言 dest 和 src 这两个指针都不为空
////	//注意返回值，也是返回目标字符串的首元素地址
////	char* ret = dest;
////	while (*dest)//找 dest 字符串的'\0'
////		dest++;
////	while (*dest++ = *src++);
////	*dest = '\0';//这两步和 strcpy 是一样的
////}
////
////int main()
////{
////	char str1[50] = "abcd";//注意目标字符串要足够大
////	char str2[] = "efghxxxxx";
////	my_strcat(str1, str2);
////	printf("%s", str1);
////	return 0;
////}
//
////#include<stdio.h>
////#include<string.h>
////
////int my_strcmp(const char* str1, const char* str2)
////{
////	while (*str1 || *str2)//当 str1 和 str2 有一个不为 '\0' 时进行循环
////	{
////		if (*str1 != *str2)
////			return *str1 - *str2;//返回的就是两个字符串中第一个不相同字符的码值的差
////		str1++, str2++;
////	}
////	return 0;
////}
////
////int main()
////{
////	char str1[] = "abcd";
////	char str2[] = "abcd";
////	char str3[] = "abce";
////	printf("%d %d", my_strcmp(str1, str2), my_strcmp(str1, str3));
////	
////	return 0;
////}
//
////#include<stdio.h>
////#include<string.h>
////
////int main()
////{
////	char str1[50] = "abcdxxxxxxxxxxxxxxxxxxxxxxxx";
////	char str2[] = "efghxxxxx";
////	strncpy(str1, str2, 13);
////	printf("%s", str1);
////	return 0;
////}
//
////#include <stdio.h>
////#include <string.h>
////int main()
////{
////	char str1[20];
////	char str2[20];
////	strcpy(str1, "To be ");//将"To be"放进 str1 中
////	strcpy(str2, "or not to be");
////
////	strncat(str1, str2, 6);
////	printf("%s\n", str1);
////	return 0;
////}
//
////#include <stdio.h>
////#include <string.h>
////
////char* my_strstr(const char* str1, const char* str2)
////{
////	while (*str1)
////	{
////		if (*str1 == *str2)
////		{
////			char* tmp1 = str1;
////			char* tmp2 = str2;
////			while (*tmp1 && *tmp2)
////			{
////				if (*tmp1 != *tmp2)
////					break;
////				tmp1++, tmp2++;
////			}
////			if (!*tmp2)//如果循环结束的时候 tmp2 是'\0'，说明上面的循环走到底了，也就是找到了
////				return str1;
////		}
////		str1++;
////	}
////	return NULL;
////}
////
////int main()
////{
////	char str[] = "This is a simple string";
////	char* pch;
////	pch = my_strstr(str, "simple");//找到 simple 第一次在 str 中出现的位置，pch指向 s.
////	strncpy(pch, "sample", 6);
////	printf("%s\n", str);
////	return 0;
////}
////
////#include <stdio.h>
////#include <string.h>
////int main()
////{
////	char arr[] = "192.168.6.111";
////	char* sep = ".";
////	char* str = NULL;
////	for (str = strtok(arr, sep); str != NULL; str = strtok(NULL, sep))
////	{
////		printf("%s\n", str);
////	}
////	return 0;
////}
//
////#include <errno.h>
////#include <string.h>
////#include <stdio.h>
//////我们打印一下0-10这些错误码对应的信息
////int main()
////{
////	int i = 0;
////	for (i = 0; i <= 10; i++) {
////		printf("%s\n", strerror(i));
////	}
////	return 0;
////}
//
//#include <stdio.h>
//#include <string.h>
//#include <errno.h>
//int main()
//{
//	FILE* pFile;
//	pFile = fopen("unexist.ent", "r");//尝试打开名为unexist.ent的文件，但是并没有，也就是打开失败了，那么 pfile 就是 NULL
//	if (pFile == NULL)
//		printf("Error opening file unexist.ent: %s\n", strerror(errno));
//	return 0;
//}